package com.yipinhouse.backstage.app.apiImpl;

import com.yipinhouse.backstage.client.BackstageQueryClient;
import com.yipinhouse.backstage.service.ShopService;
import com.yipinhouse.backstage.service.dto.AllShopDto;
import com.yipinhouse.backstage.service.dto.ShopDto;
import com.yipinhouse.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("backstage")
public class BackstageQueryApiImpl implements BackstageQueryClient {

    @Resource
    private ShopService shopService;

    /**
     * 展示所有门店
     *
     * @return
     */
    @Override
    public Result listShop() {
        List<AllShopDto> listShop = shopService.listShop();
        return Result.getInstanceList(AllShopDto.class).setData(listShop);
    }

    /**
     * 查看门店详情
     *
     * @param shopId
     * @return
     */
    @Override
    public Result checkShop(Integer shopId) {
        ShopDto shopDto = shopService.checkShop(shopId);
        return Result.getInstance(ShopDto.class).setData(shopDto);
    }
}
